#include "front/text_normalize.h"

using namespace std;
using namespace ppspeech;

const wstring mcWstrWregexWebsite = L""
	L"((https?|ftp|file)://[-A-Za-z0-9/.?=_&@%#]+)"		//url网址：http://___.___.com/?wd=____
	L"|"
	L"(www/.[-A-Za-z0-9/.?=_&@%#]+)"					//www网址：www.___.com/?wd=____
	L"|"
	L"([-A-Za-z0-9/.?=_&@%#]+\\.(com.cn|com|cn))";		//com网址：__.com，__.cn，__.com.cn

const wregex mcWregexWebsite(mcWstrWregexWebsite);


void TextNormalizer::TnReWebsite(wstring* fpInWsentence)
{
	wsmatch tWsmatch;
	while (regex_search(*fpInWsentence, tWsmatch, mcWregexWebsite)) {
		const wstring tWstrMatch = tWsmatch[0];

		//按字拆分
		vector<string> tItemWebsite;
		for(int i=0; i<tWstrMatch.size(); i++) {
			tItemWebsite.push_back( wstring2utf8string( tWstrMatch.substr(i, 1) ) );
		}
		string tStrReplace = ReplaceMethod(tItemWebsite, RME_en_website);

		WstrReplacePosition(fpInWsentence, tWsmatch.position(0), tWsmatch.length(0), utf8string2wstring(tStrReplace));
	}
}
